<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>收银台</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no"/>
	    <meta http-equiv="Access-Control-Allow-Origin" content="*">
	    <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
		<link rel="stylesheet" href="../css/base.css" />
		<link rel="stylesheet" href="../css/shouYinTai.css" />
		<script src="../js/jquery-2.2.3.min.js"></script>
		<script type="text/javascript" src="../js/rem.js"></script>
		<style>
			.shouYinTai_btn {
				margin: 0 auto;
			}
		</style>
	<body>
		<div class="header">
			<a href="javascript:history.back(-1)"><img src="../img/g_next.png" alt="" /></a>
			收银台
		</div>
		<div class="rechargeAmount">
			充值金额：<span id='money'>￥1000</span>
		</div>
		<div style="background: #FFFFFF;padding: 0.3rem 0;margin-top: 0.1rem;">
			<div class="erWeiMa">
				<div class="ZFB_erweima">
					<img id="zfb_erweima" src="../img/g_erweima.png" alt="" />
					<p>支付宝扫一扫</p>
				</div>
				<div class="wx_erweima">
					<img id="wx_erweima" src="../img/g_erweima.png" alt="" />
					<p>微信扫一扫</p>
				</div>
			</div>
		</div>
		<p class="shouYinTai_SM">
			说明：您需要支付宝或微信扫描上方进行支付，支付完成后上传支付账单详情，等待平台审核，审核通过后即为充值成功。
		</p>
		<div class="zhuanZhang_PZ">
			<p class="title">转账凭证</p>
			<div class="inp">
                <img class="inp-tx" src="../img/g_TJTP.png" alt="" />
				<input class="tx" style="top: 0;" id="file" type="file" accept="image/*" name="file">
				<input type="hidden" id='img_url'>
            </div>
			<!--<img class="Add_pictures" src="../img/g_TJTP.png" alt="" />-->
			<p class="Add_pictures_zi">点击上传转账凭证</p>
		</div>
		<input class="shouYinTai_inp" type="text" placeholder="请填写备注(选填)" />
		<input type="button" value="提交" class="shouYinTai_btn" />
	</body>


	<script src="../js/common.js"></script>
	<script src="detail/layer-v3.1.1/layer/layer.js"></script>
	<!--<script src="../js/cc.js"></script>-->

	<script>
		$(function(){
			var money=decodeURIComponent(getQueryString("money"));
			var userId=localStorage.getItem('userId');
			$('#money').html('￥'+money);

			var url=SURL+'/jfd/usersRecharge/getPaymentCode';
			//获取充值二维码
			$.get(url,{},function(e){
				if(e.code===0){
					var data=e.data;
					$('#zfb_erweima').attr('src',data.alipay);
					$('#wx_erweima').attr('src',data.wechat);
				}
			})



			//上传图片
			var image =null;
			var data = {};
            $('.shouYinTai_btn').hide()
			$('.tx').change(function(){
				var dom_obj = $(this).get(0);
                var jq_el = $(this);
				var result = new FileReader();
				result.readAsDataURL(dom_obj.files[0]);
				result.onload = function() {
					jq_el.siblings('img').attr('src',this.result);
					image = this.result;

					var url=SURL+'/jfd/upload/pictureUpload';

					var formData = new FormData();
					var file = document.getElementById("file").files[0];
					formData.append("file", file);
					//得到xhr对象
		            var xhr = null;
		            if (XMLHttpRequest) {
		                xhr = new XMLHttpRequest();
		            } else {
		                xhr = new ActiveXObject("Microsoft.XMLHTTP");
		            }

		            xhr.open("post", url, true);//设置提交方式，url，异步提交
		            xhr.onload = function () {
		                var data = xhr.responseText;    //得到返回值
		                console.log(data)
		                var data = eval('(' + data + ')');

		               	if(data.code===0){

                            // $('#img_url').val(image);
							alert('图片上传成功')
		               	 $('#img_url').val(data.data.url)
							$('.shouYinTai_btn').show()
		               	}
		            }
		            xhr.send(formData);

				}
			});





			$('.shouYinTai_btn').click(function(){
			    $(this).unbind('click');
				var remark=$('.shouYinTai_inp').val();
           		var url=SURL+'/jfd/usersRecharge/userOffline';
           		var img_url=$('#img_url').val();
           		$.post(url,{userId:userId,orderImg:img_url,cash:money,remark:remark},function(e){
           			console.log(e)
           			if(e.code===0){
           				layer.msg('充值提交成功',{time: 1500},function(){
							window.location.href='./chongZhiShenQing.html';
						})
           			}else{
						layer.msg('充值提交失败');
                        window.location.reload();
           			}
           		})
			})

			//192.168.3.115:8081/jfd/usersRecharge/userOffline

		})

	</script>

</html>
